package com.voicechat.firstmet.fragment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.ToggleButton;

import com.scwang.smartrefresh.layout.SmartRefreshLayout;
import com.scwang.smartrefresh.layout.api.RefreshLayout;
import com.scwang.smartrefresh.layout.header.ClassicsHeader;
import com.scwang.smartrefresh.layout.listener.OnRefreshListener;
import com.voicechat.firstmet.R;
import com.voicechat.firstmet.activity.AccountSettingActivity;
import com.voicechat.firstmet.activity.DynamicPageActivity;
import com.voicechat.firstmet.activity.FansAndFocusActivity;
import com.voicechat.firstmet.activity.GoldDepositsActivity;
import com.voicechat.firstmet.activity.LookMeActivity;
import com.voicechat.firstmet.activity.MemberCenterActivity;
import com.voicechat.firstmet.activity.MyShareGirlsActivity;
import com.voicechat.firstmet.activity.MySharePhotoActivity;
import com.voicechat.firstmet.activity.MyWalletActivity;
import com.voicechat.firstmet.activity.OrderAndShareGirlsActivity;
import com.voicechat.firstmet.activity.PersonDataSetActivity;
import com.voicechat.firstmet.activity.PhotoAlbumActivity;
import com.voicechat.firstmet.activity.RealNameActivity;
import com.voicechat.firstmet.activity.WebPageActivity;
import com.voicechat.firstmet.base.BaseFragment;
import com.voicechat.firstmet.bean.CharmBean;
import com.voicechat.firstmet.bean.MySelfInfoBean;
import com.voicechat.firstmet.bean.PersonDataBean;
import com.voicechat.firstmet.client.OssConfig;
import com.voicechat.firstmet.net.HTTPAPI;
import com.voicechat.firstmet.net.Params;
import com.voicechat.firstmet.net.service.MeInfoService;
import com.voicechat.firstmet.utils.GlideLoadUtils;
import com.voicechat.firstmet.utils.ParcelableUtils;
import com.voicechat.firstmet.utils.PhoneUtils;
import com.voicechat.firstmet.utils.SPUtils;
import com.voicechat.firstmet.utils.Utils;
import com.voicechat.firstmet.view.CircleImageView;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * 我的页面
 * Created by Administrator on 2018/8/28.
 */

public class MeFragment extends BaseFragment {
    /*  @BindView(R.id.circle_1)
      CircleImageView circle1;
      @BindView(R.id.circle_2)
      CircleImageView circle2;
      @BindView(R.id.circle_3)
      CircleImageView circle3;*/
    @BindView(R.id.linear_fans)
    LinearLayout linearFans;
    @BindView(R.id.linear_focus)
    LinearLayout linearFocus;
    @BindView(R.id.tv_online_state)
    TextView tvOnlineState;
    @BindView(R.id.switch_online_state)
    ToggleButton switchOnlineState;
    @BindView(R.id.tv_voice_switch)
    TextView tvVoiceSwitch;
    @BindView(R.id.switch_voice)
    ToggleButton switchVoice;
    @BindView(R.id.linear_voice)
    LinearLayout linearVoice;
    @BindView(R.id.linear_is_achor)
    LinearLayout linearIsAchor;
    @BindView(R.id.linear_sex_age)
    LinearLayout linearSexAge;
    @BindView(R.id.smart_refresh)
    SmartRefreshLayout smartRefresh;
    /*  @BindView(R.id.tv_look_num)
      TextView tvLookNum;*/
    @BindView(R.id.image_Anchor)
    ImageView imageAnchor;
    @BindView(R.id.tv_friends)
    TextView tvFriends;
    private String TAG = "MeFragment";

    @BindView(R.id.image_set)
    ImageView imageSet;
    @BindView(R.id.image_icon)
    CircleImageView imageIcon;
    @BindView(R.id.tv_nike_name)
    TextView tvNikeName;
    @BindView(R.id.image_sex)
    ImageView imageSex;
    @BindView(R.id.tv_age)
    TextView tvAge;
    @BindView(R.id.image_vip)
    ImageView imageVip;
    @BindView(R.id.tv_intro)
    TextView tvIntro;
    @BindView(R.id.tv_user_id)
    TextView tvUserId;
    @BindView(R.id.tv_fans)
    TextView tvFans;
    @BindView(R.id.tv_concern)
    TextView tvConcern;
    @BindView(R.id.tv_charm)
    TextView tvCharm;
    @BindView(R.id.tv_moneys)
    TextView tvMoneys;
    @BindView(R.id.linear_my_wallet)
    LinearLayout linearMyWallet;
    @BindView(R.id.linear_my_vip)
    LinearLayout linearMyVip;
    @BindView(R.id.linear_my_anchor)
    LinearLayout linearMyAnchor;
    @BindView(R.id.linear_my_photo)
    LinearLayout linearMyPhoto;
    @BindView(R.id.tv_charge)
    TextView tvCharge;
    @BindView(R.id.linear_my_charge)
    LinearLayout linearMyCharge;
    @BindView(R.id.linear_online_state)
    LinearLayout linearOnlineState;
    @BindView(R.id.linear_my_dynamic)
    LinearLayout linearMyDynamic;
    @BindView(R.id.linear_my_frients)
    LinearLayout linearMyFrients;

    private MySelfInfoBean.ObjectBean mySeleInfo;
    private String token;
    private String id;
    private CharmBean.ObjectBean object;

    public static MeFragment newInstance() {
        Bundle args = new Bundle();
        MeFragment fragment = new MeFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    protected int loadLayout() {
        return R.layout.fragment_me;
    }

    @Override
    protected void initLayout(Bundle savedInstanceState) {
        ButterKnife.bind(this, view);
        mySeleInfo = MySelfInfoBean.ObjectBean.CREATOR.createFromParcel(ParcelableUtils.unmarshall(
                SPUtils.getEditoString(SPUtils.SP_MYSELFINFO)));
        token = SPUtils.getEditoString(SPUtils.SP_TOKEN);
        id = mySeleInfo.getId();
        setHttp();
        //setHttpLook();
        initView();
    }

    @Override
    public void onStart() {
        super.onStart();
    }

    /**
     * @return
     * @method
     * @description 数据控件实例化
     * @date: 2018/10/24 14:09
     * @author: ljp
     */
    private void initView() {
        //设置 Header  样式
        smartRefresh.setRefreshHeader(new ClassicsHeader(context));
        smartRefresh.setOnRefreshListener(new OnRefreshListener() {
            @Override
            public void onRefresh(@NonNull RefreshLayout refreshLayout) {
                setHttpUserData();
                setHttp();
                //  setHttpLook();
                smartRefresh.finishRefresh(10000);
            }
        });
        setUserData();
    }

    /**
     * @return
     * @method
     * @description 设置用户信息
     * @date: 2018/12/28 11:03
     * @author: ljp
     */
    private void setUserData() {
        mySeleInfo = MySelfInfoBean.ObjectBean.CREATOR.createFromParcel(ParcelableUtils.unmarshall(
                SPUtils.getEditoString(SPUtils.SP_MYSELFINFO)));
        GlideLoadUtils.getInstance().glideLoad(activity, OssConfig.OSS_HTTP + mySeleInfo.getAvatarUrl(), imageIcon);
        tvNikeName.setText(mySeleInfo.getNickName());
        if (!TextUtils.isEmpty(mySeleInfo.getBirthday())) {
            tvAge.setText(Utils.getAge(mySeleInfo.getBirthday()));
        }
        tvUserId.setText("ID:" + mySeleInfo.getNumber());
        tvIntro.setText(mySeleInfo.getAutograph());
       /* if (mySeleInfo.getType() == 2) {////1普通用户2主播
            linearIsAchor.setVisibility(View.VISIBLE);
            if (mySeleInfo.getStatus() == 1) {//在线状态 1在线2隐身3离线
                switchOnlineState.setChecked(true);
                tvOnlineState.setText("在线");
            } else if (mySeleInfo.getStatus() == 2) {
                switchOnlineState.setChecked(false);
                tvOnlineState.setText("隐身");
            }
            if (mySeleInfo.getVoiceSign().equals("0")) {//一键语聊是否打开 0 打开  1关闭
                switchVoice.setChecked(true);
                tvVoiceSwitch.setText("打开");
            } else if (mySeleInfo.getVoiceSign().equals("1")) {
                switchVoice.setChecked(false);
                tvVoiceSwitch.setText("关闭");
            }
            tvCharge.setText(mySeleInfo.getGold() / 10 + "金币/分钟");
        } else {
            linearIsAchor.setVisibility(View.GONE);
        }*/
        if (mySeleInfo.getGender() == 1) {//性别  1男2女
            linearSexAge.setBackgroundResource(R.mipmap.sex_blue);
            imageSex.setImageResource(R.mipmap.boy);
        } else {
            linearSexAge.setBackgroundResource(R.mipmap.sex_red);
            imageSex.setImageResource(R.mipmap.girl);
        }
        if (!TextUtils.isEmpty(mySeleInfo.getvType())) {
            if (mySeleInfo.getvType().equals("0")) {// 会员等级 0非会员 1月会员 2年会员
                imageVip.setVisibility(View.GONE);
            } else if (mySeleInfo.getvType().equals("1")) {
                imageVip.setVisibility(View.VISIBLE);
                imageVip.setImageResource(R.mipmap.vip_month);
            } else if (mySeleInfo.getvType().equals("2")) {
                imageVip.setVisibility(View.VISIBLE);
                imageVip.setImageResource(R.mipmap.vip_year);
            }
        }
        if (mySeleInfo.getType() == 2) {//1普通用户2主播
            imageAnchor.setVisibility(View.VISIBLE);
            GlideLoadUtils.getInstance().glideLoad(context, OssConfig.OSS_HTTP + mySeleInfo.getExclusiveUrl(),
                    imageAnchor);
        } else {
            imageAnchor.setVisibility(View.GONE);
        }
        switchOnlineState.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                tvOnlineState.setText(switchOnlineState.isChecked() ? "在线" : "隐身");
                setHttpOnLineState();
            }
        });
        switchVoice.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                tvVoiceSwitch.setText(switchVoice.isChecked() ? "开启" : "关闭");
                setHttpVoiceState();
            }
        });
    }

    /**
     * @return
     * @method
     * @description 改变在线状态
     * @date: 2018/11/15 18:48
     * @author: ljp
     */
    private void setHttpOnLineState() {
        Params params = new Params();
        params.put("status", switchOnlineState.isChecked() ? "1" : "2");
        params.put("id", mySeleInfo.getId());
        params.put("mobile", SPUtils.getEditoString(SPUtils.SP_PHONE));//手机号码
        params.put("token", token);//token
        params.put("equipmentId", PhoneUtils.getDeviceInfo(context));//设备号
        MeInfoService.updateData(params).subscribe(mySelfInfoBean -> {
            //Log.i(TAG, "setHttpOnLineState: ----"+mySelfInfoBean.getCode());
            Log.i(TAG, "setHttpOnLineState: ----" + mySelfInfoBean.getCode());
            if (mySelfInfoBean.getCode() == HTTPAPI.RETURN_CODE_TYPE.RETRUN_SUCCESS) {
                this.mySeleInfo.setStatus(mySelfInfoBean.getObject().getStatus());
                SPUtils.setEditorKeyValue(SPUtils.SP_MYSELFINFO, ParcelableUtils.marshall(mySeleInfo));
            } else if (mySelfInfoBean.getCode() == HTTPAPI.RETURN_CODE_TYPE.RETURN_NO_TOKEN) {
                Utils.setToken(context);
            } else {
                toast_MakeText(mySelfInfoBean.getMsg());
            }
        }, throwable -> {
            toast_MakeText(getResources().getString(R.string.net_error));
        });

    }

    /**
     * @return
     * @method
     * @description 改变一键语聊
     * @date: 2018/11/15 18:48
     * @author: ljp
     */
    private void setHttpVoiceState() {
        Params params = new Params();
        params.put("voiceSign", switchVoice.isChecked() ? "0" : "1");
        params.put("id", mySeleInfo.getId());
        params.put("mobile", SPUtils.getEditoString(SPUtils.SP_PHONE));//手机号码
        params.put("token", token);//token
        params.put("equipmentId", PhoneUtils.getDeviceInfo(context));//设备号
        MeInfoService.updateData(params).subscribe(mySelfInfoBean -> {
            //Log.i(TAG, "setHttpOnLineState: ----"+mySelfInfoBean.getCode());
            Log.i(TAG, "setHttpOnLineState: ----" + mySelfInfoBean.getCode());
            if (mySelfInfoBean.getCode() == HTTPAPI.RETURN_CODE_TYPE.RETRUN_SUCCESS) {
                this.mySeleInfo.setVoiceSign(switchVoice.isChecked() ? "0" : "1");
                SPUtils.setEditorKeyValue(SPUtils.SP_MYSELFINFO, ParcelableUtils.marshall(mySeleInfo));
            } else if (mySelfInfoBean.getCode() == HTTPAPI.RETURN_CODE_TYPE.RETURN_NO_TOKEN) {
                Utils.setToken(context);
            } else {
                toast_MakeText(mySelfInfoBean.getMsg());
            }
        }, throwable -> {
            toast_MakeText(getResources().getString(R.string.net_error));
        });
    }

    /**
     * @return
     * @method
     * @description 数据请求, 请求个人信息
     * @date: 2018/10/24 16:04
     * @author: ljp
     */
    private void setHttpUserData() {
        MeInfoService.selectUserData(SPUtils.getEditoString(SPUtils.SP_PHONE), token, PhoneUtils.getDeviceInfo(context)).subscribe(mySelfInfoBean -> {
            Log.i(TAG, "setHttpUserData: ---mySelfInfoBean---" + mySelfInfoBean.getObject().toString());
            if (mySelfInfoBean.getCode() == HTTPAPI.RETURN_CODE_TYPE.RETRUN_SUCCESS) {
                SPUtils.setEditorKeyValue(SPUtils.SP_MYSELFINFO, ParcelableUtils.marshall(mySelfInfoBean.getObject()));
                setUserData();
            } else if (mySelfInfoBean.getCode() == HTTPAPI.RETURN_CODE_TYPE.RETURN_NO_TOKEN) {
                Utils.setToken(context);
            } else {
                toast_MakeText(mySelfInfoBean.getMsg());
            }
        }, throwable -> {
            Log.i(TAG, "setHttp: ------" + throwable.toString());

        });
    }

    /**
     * @return
     * @method
     * @description 数据请求, 显示魅力值等信息
     * @date: 2018/10/24 16:04
     * @author: ljp
     */
    private void setHttp() {
        MeInfoService.showState(token, PhoneUtils.getDeviceInfo(context), id, id).subscribe(charmBean -> {
            Log.i(TAG, "setHttp: ---charmBean---" + charmBean.getCode());
            if (charmBean.getCode() == HTTPAPI.RETURN_CODE_TYPE.RETRUN_SUCCESS) {
                Log.i(TAG, "setHttp: ---charmBean---" + charmBean.getObject().toString());
                object = charmBean.getObject();
                initShowDate();
                if (smartRefresh != null) {
                    smartRefresh.finishRefresh();
                }
            } else if (charmBean.getCode() == HTTPAPI.RETURN_CODE_TYPE.RETURN_NO_TOKEN) {
                Utils.setToken(context);
            } else {
                toast_MakeText(charmBean.getMsg());
            }
        }, throwable -> {
            Log.i(TAG, "setHttp: ------" + throwable.toString());

        });
    }

    /**
     * @return
     * @method
     * @description 数据请求, 显示谁看过我相关信息
     * @date: 2018/10/24 16:04
     * @author: ljp
     */
   /* private void setHttpLook() {
        MeInfoService.showLook(token, PhoneUtils.getDeviceInfo(context), id).subscribe(charmBean -> {
            Log.i(TAG, "setHttpLook: -------"+charmBean.getCode());
            if (charmBean.getCode() == HTTPAPI.RETURN_CODE_TYPE.RETRUN_SUCCESS) {
                // Log.i(TAG, "setHttpLook: ------" + charmBean.getList().size());
                if (charmBean.getList() == null) {
                    relaLookme.setVisibility(View.GONE);
                } else {
                    List<CharmBean.ObjectBean> objectBeans = charmBean.getList();
                    initLookData(objectBeans);
                }
                if (smartRefresh != null) {
                    smartRefresh.finishRefresh();
                }
            } else if (charmBean.getCode() == HTTPAPI.RETURN_CODE_TYPE.RETURN_NO_TOKEN) {
                Utils.setToken(context);
            } else {
                toast_MakeText(charmBean.getMsg());
            }
        }, throwable -> {
            Log.i(TAG, "setHttpLook: ------" + throwable.toString());

        });
    }*/

    /**
     * @return
     * @method
     * @description 谁看过我数据实例化
     * @date: 2018/10/26 14:25
     * @author: ljp
     */
   /* private void initLookData(List<CharmBean.ObjectBean> objectBeans) {
        CircleImageView[] circleImageViews = {circle3, circle2, circle1};
        tvLookNum.setText(objectBeans.get(0).getCount());
        for (int i = 0; i < objectBeans.size(); i++) {
            String avatarUrl = objectBeans.get(i).getAvatarUrl();
            CircleImageView circleImageView = circleImageViews[i];
            //Log.i(TAG, "initLookData: -----"+circleImageView);
            GlideLoadUtils.getInstance().glideLoad(activity, OssConfig.OSS_HTTP + avatarUrl, circleImageView);
        }
    }*/

    /**
     * @return
     * @method
     * @description 魅力值数据显示
     * @date: 2018/10/24 16:05
     * @author: ljp
     */
    private void initShowDate() {
        tvFans.setText(object.getFans());
        tvConcern.setText(object.getFollow());
        tvCharm.setText("魅力值：" + object.getTotalIncome());
        tvMoneys.setText("土豪值：" + object.getWealth());
        tvFriends.setText(object.getFriendCount()+"");
        //linearIsAchor.setVisibility(View.GONE);
        /*if (mySeleInfo.getType() == 2) {////1普通用户2主播
            linearIsAchor.setVisibility(View.VISIBLE);
            if (mySeleInfo.getStatus() == 1) {//在线状态 1在线2隐身3离线
                switchOnlineState.setChecked(true);
                tvOnlineState.setText("在线");
            } else if (mySeleInfo.getStatus() == 2) {
                switchOnlineState.setChecked(false);
                tvOnlineState.setText("隐身");
            }
            if (mySeleInfo.getVoiceSign().equals("0")) {//一键语聊是否打开 0 打开  1关闭
                switchVoice.setChecked(true);
                tvVoiceSwitch.setText("打开");
            } else if (mySeleInfo.getVoiceSign().equals("1")) {
                switchVoice.setChecked(false);
                tvVoiceSwitch.setText("关闭");
            }
            tvCharge.setText(mySeleInfo.getGold() / 10 + "金币/分钟");
        } else {
            linearIsAchor.setVisibility(View.GONE);
        }*/
    }


    @OnClick({R.id.image_set, R.id.image_icon, R.id.linear_my_wallet, R.id.linear_my_vip,
            R.id.linear_my_anchor, R.id.linear_my_photo,
            R.id.linear_my_charge, R.id.linear_my_dynamic,
            R.id.linear_friends,
            R.id.linear_my_frients, R.id.linear_my_picture, R.id.linear_yy_order,
            R.id.linear_fans, R.id.linear_focus, R.id.switch_online_state,
            R.id.switch_voice, R.id.linear_my_share_girls,R.id.tv_recharge})
    public void onClick(View view) {
        Intent intent = null;
        switch (view.getId()) {
            case R.id.image_set://个人设置
                startActivity(new Intent(context, AccountSettingActivity.class));
                break;
            case R.id.image_icon://个人资料设置
                startActivity(new Intent(context, PersonDataSetActivity.class));
                break;
            case R.id.linear_my_wallet://我的钱包
                context.startActivity(new Intent(context, MyWalletActivity.class));
                break;
            case R.id.linear_my_vip://我的vip设置
                context.startActivity(new Intent(context, MemberCenterActivity.class));
                break;
            case R.id.linear_my_anchor://认证主播
                intent = new Intent(activity, WebPageActivity.class);
                intent.putExtra("url", HTTPAPI.URL_BASE + HTTPAPI.URL_ANCHOR);
                intent.putExtra("title", "认证主播");
                startActivity(intent);
                break;
            case R.id.linear_my_photo://我的相册
                intent = new Intent(activity, PhotoAlbumActivity.class);
                intent.putExtra("anchorId", id);
                startActivity(intent);
                break;
            case R.id.linear_my_charge://收费设置
                // startActivity(new Intent(activity, ChargingSetActivity.class));
                break;
            //case R.id.linear_real_name://实名认证
            //    judeRealName();
            //    break;
            case R.id.linear_my_dynamic://我的动态
                intent = new Intent(activity, DynamicPageActivity.class);
                intent.putExtra("anchorId", id);
                startActivity(intent);
                break;
            case R.id.linear_wo_look_me://谁看过我
                intent = new Intent(activity, LookMeActivity.class);
                intent.putExtra("vType", mySeleInfo.getvType());
                startActivity(intent);
                break;
            case R.id.linear_my_frients://邀请好友
                intent = new Intent(activity, WebPageActivity.class);
                intent.putExtra("url", HTTPAPI.URL_BASE + HTTPAPI.URL_FRIENDS);
                intent.putExtra("userId", mySeleInfo.getId());
                intent.putExtra("title", "邀请好友");
                startActivity(intent);
                break;
            //  case R.id.linear_my_task://我的任务
            //     startActivity(new Intent(activity, MyAssignmentsActivity.class));
            //     break;
            //  case R.id.linear_service://客服与帮助
            //      startActivity(new Intent(activity, ServiceAndHelpActivity.class));
            //     break;
            case R.id.linear_fans://我的粉丝
                intent = new Intent(activity, FansAndFocusActivity.class);
                intent.putExtra("flag", "1");
                startActivity(intent);
                break;
            case R.id.linear_focus://我的关注
                intent = new Intent(activity, FansAndFocusActivity.class);
                intent.putExtra("flag", "0");
                startActivity(intent);
                break;
            case R.id.linear_friends://隐友
                intent = new Intent(activity, FansAndFocusActivity.class);
                intent.putExtra("flag", "2");
                startActivity(intent);
                break;
            case R.id.linear_my_picture://我的秀照
                context.startActivity(new Intent(activity, MySharePhotoActivity.class));
                break;
            case R.id.linear_yy_order://隐约订单linear_my_share_girls
                context.startActivity(new Intent(activity, OrderAndShareGirlsActivity.class));
                break;
            case R.id.linear_my_share_girls://我的闺蜜
                context.startActivity(new Intent(activity, MyShareGirlsActivity.class));
                break;
            case R.id.tv_recharge://充值
                initHttp();
                break;
        }
    }
    /**
     * @method
     * @description 余额请求
     * @date: 2018/11/7 14:39
     * @author: ljp
     * @return
     */
    private void initHttp() {
        MeInfoService.goldDiamond(mySeleInfo.getId(),token,PhoneUtils.getDeviceInfo(context)).subscribe(goldBean -> {
            //Log.i(TAG, "initHttp: -------"+goldBean.getObject().toString());
            if(goldBean.getCode() == HTTPAPI.RETURN_CODE_TYPE.RETRUN_SUCCESS){
                Intent intent = new Intent(activity, GoldDepositsActivity.class);
                intent.putExtra("diamondSum",goldBean.getObject().getGold());
                startActivity(intent);
            }else if(goldBean.getCode() == HTTPAPI.RETURN_CODE_TYPE.RETURN_NO_TOKEN) {
                Utils.setToken(context);
            }else {
                toast_MakeText(goldBean.getMsg());
            }
        },throwable -> {
            Log.i(TAG, "initHttp: -----"+throwable.toString());
        });
    }
    /**
     * @return
     * @method
     * @description 实名认证状态判断
     * @date: 2018/11/6 15:07
     * @author: ljp
     */
    private void judeRealName() {
        Intent intent = null;
        //判断是否提交过实名认证信息
        if (mySeleInfo.getIsAttestation() == 0) {// 实名认证任务 0未认证 1 已审核 2 审核中 3驳回
            intent = new Intent(activity, RealNameActivity.class);
            startActivity(intent);
        } else {//上传过就去判断，实名认证的当前的状态
            MeInfoService.certificationSelect(id, token, PhoneUtils.getDeviceInfo(context)).subscribe(personDataBean -> {
                if (personDataBean.getCode() == HTTPAPI.RETURN_CODE_TYPE.RETRUN_SUCCESS) {
                    //判断state状态  认证状态 0审核中 1审核通过 2驳回
                    PersonDataBean.ObjectBean object = personDataBean.getObject();
                    if (object.getStatus() == 0) {
                        toast_MakeText(getResources().getString(R.string.real_name));
                    } else if (object.getStatus() == 1) {
                        Intent intent2 = new Intent(activity, RealNameActivity.class);
                        intent2.putExtra("object", object);
                        startActivity(intent2);
                    } else if (object.getStatus() == 2) {
                        toast_MakeText(getResources().getString(R.string.real_name_no));
                        Intent intent3 = new Intent(activity, RealNameActivity.class);
                        startActivity(intent3);
                    }
                } else if (personDataBean.getCode() == HTTPAPI.RETURN_CODE_TYPE.RETURN_NO_TOKEN) {
                    Utils.setToken(context);
                } else {
                    toast_MakeText(personDataBean.getMsg());
                }
            }, throwable -> {
                Log.i(TAG, "judeRealName: ---------" + throwable.toString());

            });

        }
    }

    @OnClick(R.id.rela_data)
    public void onClick() {
        startActivity(new Intent(context, PersonDataSetActivity.class));
    }

}
